package com.crm.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.crm.entity.CrmDataValue;
import com.crm.mapper.CrmDataValueMapper;
import com.crm.service.ICrmDataValueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author junxian,dou
 * @since 2024-11-25
 */
@Service
public class CrmDataValueServiceImpl extends ServiceImpl<CrmDataValueMapper, CrmDataValue> implements ICrmDataValueService {


    @Override
    public List<CrmDataValue> getDataVluesByCode(String codeName) {
        if (ObjectUtil.isEmpty(codeName)) return Collections.emptyList();

        LambdaQueryWrapper<CrmDataValue> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CrmDataValue::getTypeCode,codeName);
        wrapper.orderByDesc(CrmDataValue::getId);
        wrapper.select(CrmDataValue::getId,CrmDataValue::getValue);
        List<CrmDataValue> list = this.list(wrapper);
        return list;
    }
}
